$(function () {
    var  dateValue;
    layui.use(['table','laydate'], function(){
        var table = layui.table;
        var laydate = layui.laydate;
        function loadTime(laydate){
            laydate.render({
                elem: '#test1' //指定元素
                ,range: true
                ,type:"date"
                ,calendar: true
                ,done: function(value, date, endDate){
                    dateValue=value;
                    loadTime(laydate)
                }
            });
        }
        loadTime(laydate)
        table.render({
            elem: '#log'
            ,url:'/log/getData'
            ,toolbar:'#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            ,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义，去除该参数即可
                title: '提示'
                ,layEvent: 'LAYTABLE_TIPS'
                ,icon: 'layui-icon-tips'
            }]
            ,title: '日志数据'
            ,cols: [[
                {type: 'checkbox', fixed: 'left'}
                ,{field:'logId', title:'日志id', width:183}
                ,{field:'motion', title:'事件', width:138}
                ,{field:'userId', title:'用户id', width:133}
                ,{field:'userName', title:'用户名', width:116}
                ,{field:'logTime', title:'时间', width:195,templet:function (d){
                        return formatDate(d);
                    }}
                ,{field:'source', title:'来源',width:160}
                ,{field:'computerIP', title:'主机ip', width:170}
                ,{field:'decs', title:'备注', width:120, sort: true,edit: 'text'}
            ]]
            ,page: true
            ,id:"dataTable"
        });

        $("#seek").click(function () {
            table.reload("dataTable", {
                url: "/log/selectDate"
                ,where: {
                    condition:dateValue
                    ,motion:$("#motion").val()
                    ,userName:$("#userName").val()
                    ,logId:$("#logId").val()
                }
            });

        })



    });










})

